import { defineStore } from "pinia";

export const useTodoStore = defineStore("todo", {
  state: () => ({
    tasks: [],
  }),
  actions: {
    addTask(taskName) {
      this.tasks.push({ id: Date.now(), name: taskName, finished: false });
    },
    removeTask(taskId) {
      this.tasks = this.tasks.filter((task) => {
        return task.id !== taskId;
      });
    },
  },
  persist: {
    enabled: true,
  },
});
